import java.util.Scanner;

public class demo03 {
    //带分数
    public static int count=0;
    public static int n;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        int[] arr={1,2,3,4,5,6,7,8,9};
        dfs(arr,0);
        System.out.println(count);
    }
    public static void dfs(int[] arr,int i){
        if(i==9){
            check(arr);
            return;
        }
        for (int j = i; j < 9; j++) {
            swap(arr,j,i);
            dfs(arr,i+1);
            swap(arr,j,i);
        }
    }
    public static void swap(int[] arr,int i,int j){
        int tmp=arr[i];
        arr[i]=arr[j];
        arr[j]=tmp;
    }
    public static void check(int[] arr){
        for (int i = 0; i < 7; i++) {
            int num1=tonum(arr,0,i);
            if(num1>=n){
                return;
            }
            for (int j = i+1; j <= 7; j++) {
                int num2=tonum(arr,i+1,j);
                int num3=tonum(arr,j+1,8);
                if(num2%num3==0&&num2/num3+num1==n){
                    count++;
                }
            }
        }
    }
    public static int tonum(int[] arr,int i,int j){
        int n=arr[i];
        while (i<j){
            n*=10;
            n+=arr[i+1];
            i++;
        }
        return n;
    }
}
